import { Alert } from "antd";

export interface TableSelectionAlertProp {
  selectedRowKeys: any[];
  onClickCancel?: () => void;
}

export default function TableSelectionAlert(props: TableSelectionAlertProp) {
  const { selectedRowKeys } = props;
  if (!selectedRowKeys.length) return null;
  return (
    <Alert
      style={{ marginBottom: 16 }}
      message={
        <div className={"ui-flex"}>
          <span>已选择 {selectedRowKeys.length} 项</span>
          <a className="ant-dropdown-link" onClick={e => {
            e.preventDefault();
            props.onClickCancel && props.onClickCancel();
          }}>
            取消选择
          </a>
        </div>
      }
      type="info"
    />
  )
}